package com.surenpi.jenkins.client.folder;

import com.google.common.collect.ImmutableMap;
import com.surenpi.jenkins.client.BaseManager;
import com.surenpi.jenkins.client.util.EncodingUtils;
import com.surenpi.jenkins.client.util.UrlUtils;
import java.io.IOException;

public class Folders extends BaseManager {
   private String folderCls = "com.cloudbees.hudson.plugins.folder.Folder";

   public void create(FolderJob folderJob, String folderName, Boolean crumbFlag) throws IOException {
      ImmutableMap<String, String> params = ImmutableMap.of("mode", this.folderCls, "name", EncodingUtils.encodeParam(folderName), "from", "", "Submit", "OK");
      this.getClient().postForm(UrlUtils.toBaseUrl(folderJob) + "createItem?", params, crumbFlag);
   }

   public void create(String folderName, Boolean crumbFlag) throws IOException {
      this.create((FolderJob)null, folderName, crumbFlag);
   }

   public void create(String folderName) throws IOException {
      this.create(folderName, this.isCrumb());
   }

   public String getXml(String folderName) throws IOException {
      return this.getClient().get("/job/" + EncodingUtils.encode(folderName) + "/config.xml");
   }

   public boolean exists(String folderName) throws IOException {
      try {
         return this.getXml(folderName) != null;
      } catch (Exception var3) {
         return false;
      }
   }

   public String getFolderCls() {
      return this.folderCls;
   }

   public void setFolderCls(String folderCls) {
      this.folderCls = folderCls;
   }

   protected String[] getDependencyArray() {
      return new String[0];
   }
}
